package com.example.service.authcenter.cscec5b;

import com.example.entity.authcenter.cscec5b.ExternalSystemOrganizationDTO;
import com.example.entity.authcenter.cscec5b.ExternalSystemResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * XXX
 *
 * @author : jamesfu
 * @date : 9/7/2019
 * @time : 3:31 PM
 */
@Service
public class Cscec5bOrganizationService {

    private static final String ORG_URL = "http://172.30.201.51:29559/zj5b/datas//corp/?token=12";

    @Autowired
    private RestTemplate restTemplate;

    public List<ExternalSystemOrganizationDTO> getOrganizationList() {
        ResponseEntity<ExternalSystemResponseDTO<List<ExternalSystemOrganizationDTO>>> responseEntity = restTemplate.exchange(ORG_URL,
                HttpMethod.GET,
                null,
                new ParameterizedTypeReference<ExternalSystemResponseDTO<List<ExternalSystemOrganizationDTO>>>() {
                });

        return responseEntity.getBody().getData();
    }
}
